
#include <BMap>
#include <BStyle>
#include <BFont>
#include <BFile>
#include <BLabel>
#include <BButton>
#include <BSpinBox>
#include <BPainter>
#include <BDateEdit>
#include <BTimeEdit>
#include <BLineEdit>
#include <BTextEdit>
#include <BCheckBox>
#include <BGridLayout>
#include <BVBoxLayout>
#include <BHBoxLayout>
#include <BStackLayout>
#include <BXmlDocument>
#include <BSonDocument>
#include <BFloatSpinBox>
#include <BDoubleSpinBox>
#include <BRealSpinBox>
#include <BFileDialog>
#include <BColorDialog>
#include <BMessageBox>
#include <BTreeWidget>
#include <BListWidget>
#include <BReadWrite>
#include <BIcon>
#include <BCursor>
#include <BSystem>
#include <BStyleDocument>
#include <BApplication>

#include "MainWindow.h"

MainWindow::MainWindow()
{
	//this->setFrameless(true);

	_treeWidget = new BTreeWidget();
	_treeWidget->setName("tree");
	_treeWidget->setIndent(23);

	BWidget* rightWidget = new BWidget();
	{
		BHBoxLayout* topLayout = new BHBoxLayout();
		topLayout->setHeightPolicy(Policy_Preferred);
		{
			BLabel* fileNameLabel = new BLabel("fileName");
			_fileNameEdit = new BLineEdit();

			_browseFileButton = new BButton(" ... ");
			_browseFileButton->setTips("browse file");

			_saveFileButton = new BButton("Save");
			_saveFileButton->setEnabled(false);

			_loadFileButton = new BButton("Load");

			topLayout->addWidget(fileNameLabel);
			topLayout->addWidget(_fileNameEdit, 100);
			topLayout->addWidget(_browseFileButton);
			topLayout->addWidget(_loadFileButton);
			topLayout->addWidget(_saveFileButton);
		}

		_styleSheetEdit = new StyleEdit;

		BVBoxLayout* vlayout = new BVBoxLayout(rightWidget);
		vlayout->setSplitable(true);
		vlayout->setSpacing(8);
		vlayout->addLayout(topLayout, 0);
		vlayout->addWidget(_styleSheetEdit, 1000);
	}

	_tableWidget = new BTableWidget();
	_tableWidget->setGridStyle(Grid_Crossing);

	BHBoxLayout* splitLayout = new BHBoxLayout();
	splitLayout->setSpacing(10);
	splitLayout->setSplitable(true);
	splitLayout->addWidget(_treeWidget);
	splitLayout->addWidget(rightWidget, 10);
	splitLayout->addWidget(_tableWidget);

	BVBoxLayout* layout = new BVBoxLayout(this);
	layout->addLayout(splitLayout);

	connect(_fileNameEdit, Signal_EditFinished, &MainWindow::slotSheetFileNameEdited);
	connect(_browseFileButton, Signal_Clicked, &MainWindow::slotBrowseFileButtonClicked);
	connect(_loadFileButton, Signal_Clicked, &MainWindow::slotLoadButtonClicked);
	connect(_saveFileButton, Signal_Clicked, &MainWindow::slotSaveSheetButtonClicked);
	connect(_styleSheetEdit, Signal_EditFinished, &MainWindow::slotStyleSheetEdited);
	connect(_treeWidget, Signal_ItemSelected, &MainWindow::slotTreeItemSelected);

}
MainWindow::~MainWindow()
{

}

BTreeItem* MainWindow::createTreeItem(BXmlNode* node)
{
	if (node)
	{
		BTreeItem* item = new BTreeItem(node->name());
		item->setAsset(node);

		const BMap<BString, BString>& attribs = node->attribSet();
		for (auto it = attribs.begin(); it.valid(); ++it)
		{
			BString text;
			text << '[' << it.key() << " = " << it.value() << ']';
			BTreeItem* child = item->addChild(text);
			assignIcon(child);
		}

		if (node->text().size())
		{
			BTreeItem* child = item->addChild(node->text());
			assignIcon(child);
		}

		for (int i = 0; i < node->childCount(); i++)
		{
			BXmlNode* childNode = node->child(i);
			BTreeItem* childItem = createTreeItem(childNode);
			item->addChild(childItem);
		}
		assignIcon(item);
		return item;
	}
	return 0;
}
BTreeItem* MainWindow::createTreeItem(BSonNode* node)
{
	if (node)
	{
		BTreeItem* item = new BTreeItem(node->name());
		item->setAsset(node);

		const BMap<BString, BString>& attribs = node->attribSet();
		for (auto it = attribs.begin(); it.valid(); ++it)
		{
			BString text;
			text << '[' << it.key() << " = " << it.value() << ']';
			BTreeItem* child = item->addChild(text);
			assignIcon(child);
		}

		if (node->text().size())
		{
			BTreeItem* child = item->addChild(node->text());
			child->setAlign(Align_None);
			assignIcon(child);
		}

		for (int i = 0; i < node->childCount(); i++)
		{
			BSonNode* childNode = node->child(i);
			BTreeItem* childItem = createTreeItem(childNode);
			item->addChild(childItem);
		}
		assignIcon(item);
		return item;
	}
	return 0;
}
bool MainWindow::assignIcon(BTreeItem* item)
{
	const BStyle* style = this->realStyle();
	if (item->asset().valid())
	{
		item->setIcon(style->icon("node"));
		return true;
	}
	if (item->text().beginWith('[') && item->text().endWith(']'))
		item->setIcon(style->icon("attrib"));
	else
		item->setIcon(style->icon("text"));
	return true;
}
BTreeItem* MainWindow::createTreeItem(BStyle* style)
{
	BTreeItem* item = new BTreeItem();
	if (style->name().size())
		item->setText(style->type() + '#' + style->name());
	else
		item->setText(style->type());
	item->setAsset(style);
	if (style->subCount() > 0)
	{
		BTreeItem* groupItem = new BTreeItem(_subsIcon, "subs");
		for (int i = 0; i < style->subCount(); i++)
		{
			BStyle* sub = style->sub(i);
			BTreeItem* subItem = createTreeItem(sub);
			groupItem->addChild(subItem);
		}
		item->addChild(groupItem);
	}
	for (int i = 0; i < style->childCount(); i++)
	{
		BStyle* child = style->child(i);
		BTreeItem* childItem = createTreeItem(child);
		childItem->setIcon(_itemIcon);
		item->addChild(childItem);
	}
	return item;
}

#define CASE_MACRO_CSTR(m)	case m: return #m;

BString MainWindow::sroleToString(StyleRole srole)
{
	switch (srole)
	{
		CASE_MACRO_CSTR(Value_Icon);
		CASE_MACRO_CSTR(Value_Image);
		CASE_MACRO_CSTR(Value_Graph);
		CASE_MACRO_CSTR(Value_Title);
		CASE_MACRO_CSTR(Value_Width);
		CASE_MACRO_CSTR(Value_Height);
		CASE_MACRO_CSTR(Value_Form);
		CASE_MACRO_CSTR(Value_Align);
		CASE_MACRO_CSTR(Value_Space);
		CASE_MACRO_CSTR(Value_Border);

		CASE_MACRO_CSTR(Value_Perch_Left);
		CASE_MACRO_CSTR(Value_Perch_Right);
		CASE_MACRO_CSTR(Value_Perch_Top);
		CASE_MACRO_CSTR(Value_Perch_Bottom);

		CASE_MACRO_CSTR(Value_Margin_Left);
		CASE_MACRO_CSTR(Value_Margin_Right);
		CASE_MACRO_CSTR(Value_Margin_Top);
		CASE_MACRO_CSTR(Value_Margin_Bottom);

		CASE_MACRO_CSTR(Value_Icon_Size);
		CASE_MACRO_CSTR(Value_Arrow_Size);
		CASE_MACRO_CSTR(Value_Handle_Size);
		CASE_MACRO_CSTR(Value_Wire_Size);
		CASE_MACRO_CSTR(Value_Groove_Size);
		CASE_MACRO_CSTR(Value_Separator_Size);
		CASE_MACRO_CSTR(Value_Row_Space);
		CASE_MACRO_CSTR(Value_Column_Space);

		CASE_MACRO_CSTR(Color_Title);
		CASE_MACRO_CSTR(Color_Title_Hovered);
		CASE_MACRO_CSTR(Color_Title_Pressed);
		CASE_MACRO_CSTR(Color_Title_Checked);
		CASE_MACRO_CSTR(Color_Title_Disable);

		CASE_MACRO_CSTR(Color_Title_Text);
		CASE_MACRO_CSTR(Color_Title_Text_Hovered);
		CASE_MACRO_CSTR(Color_Title_Text_Pressed);
		CASE_MACRO_CSTR(Color_Title_Text_Checked);
		CASE_MACRO_CSTR(Color_Title_Text_Disable);

		CASE_MACRO_CSTR(Color_Text);
		CASE_MACRO_CSTR(Color_Text_Hovered);
		CASE_MACRO_CSTR(Color_Text_Pressed);
		CASE_MACRO_CSTR(Color_Text_Checked);
		CASE_MACRO_CSTR(Color_Text_Disable);

		CASE_MACRO_CSTR(Color_Background);
		CASE_MACRO_CSTR(Color_Background_Hovered);
		CASE_MACRO_CSTR(Color_Background_Pressed);
		CASE_MACRO_CSTR(Color_Background_Checked);
		CASE_MACRO_CSTR(Color_Background_Disable);

		CASE_MACRO_CSTR(Color_Border);
		CASE_MACRO_CSTR(Color_Border_Hovered);
		CASE_MACRO_CSTR(Color_Border_Pressed);
		CASE_MACRO_CSTR(Color_Border_Checked);
		CASE_MACRO_CSTR(Color_Border_Disable);

		CASE_MACRO_CSTR(Color_Perch);
		CASE_MACRO_CSTR(Color_Perch_Hovered);
		CASE_MACRO_CSTR(Color_Perch_Pressed);
		CASE_MACRO_CSTR(Color_Perch_Checked);
		CASE_MACRO_CSTR(Color_Perch_Disable);

		CASE_MACRO_CSTR(Color_Margin);
		CASE_MACRO_CSTR(Color_Margin_Hovered);
		CASE_MACRO_CSTR(Color_Margin_Pressed);
		CASE_MACRO_CSTR(Color_Margin_Checked);
		CASE_MACRO_CSTR(Color_Margin_Disable);

		CASE_MACRO_CSTR(Color_Handle);
		CASE_MACRO_CSTR(Color_Handle_Hovered);
		CASE_MACRO_CSTR(Color_Handle_Pressed);
		CASE_MACRO_CSTR(Color_Handle_Checked);
		CASE_MACRO_CSTR(Color_Handle_Disable);

		CASE_MACRO_CSTR(Color_Arrow);
		CASE_MACRO_CSTR(Color_Arrow_Hovered);
		CASE_MACRO_CSTR(Color_Arrow_Pressed);
		CASE_MACRO_CSTR(Color_Arrow_Checked);
		CASE_MACRO_CSTR(Color_Arrow_Disable);

		CASE_MACRO_CSTR(Color_Tab);
		CASE_MACRO_CSTR(Color_Tab_Hovered);
		CASE_MACRO_CSTR(Color_Tab_Pressed);
		CASE_MACRO_CSTR(Color_Tab_Checked);
		CASE_MACRO_CSTR(Color_Tab_Disable);

		CASE_MACRO_CSTR(Color_Header);
		CASE_MACRO_CSTR(Color_Header_Hovered);
		CASE_MACRO_CSTR(Color_Header_Pressed);
		CASE_MACRO_CSTR(Color_Header_Checked);
		CASE_MACRO_CSTR(Color_Header_Disable);

		CASE_MACRO_CSTR(Color_Item);
		CASE_MACRO_CSTR(Color_Item_Hovered);
		CASE_MACRO_CSTR(Color_Item_Pressed);
		CASE_MACRO_CSTR(Color_Item_Checked);
		CASE_MACRO_CSTR(Color_Item_Disable);

		CASE_MACRO_CSTR(Color_Prefix);
		CASE_MACRO_CSTR(Color_Prefix_Hovered);
		CASE_MACRO_CSTR(Color_Prefix_Pressed);
		CASE_MACRO_CSTR(Color_Prefix_Disable);

		CASE_MACRO_CSTR(Color_Suffix);
		CASE_MACRO_CSTR(Color_Suffix_Hovered);
		CASE_MACRO_CSTR(Color_Suffix_Pressed);
		CASE_MACRO_CSTR(Color_Suffix_Disable);

		CASE_MACRO_CSTR(Color_Wire);
		CASE_MACRO_CSTR(Color_Chunk);
		CASE_MACRO_CSTR(Color_Groove);
		CASE_MACRO_CSTR(Color_Separator);
		CASE_MACRO_CSTR(Color_Indicator);
		CASE_MACRO_CSTR(Color_Grid_Ver);
		CASE_MACRO_CSTR(Color_Grid_Hor);

		CASE_MACRO_CSTR(Image_Title);
		CASE_MACRO_CSTR(Image_Title_Hovered);
		CASE_MACRO_CSTR(Image_Title_Pressed);
		CASE_MACRO_CSTR(Image_Title_Checked);
		CASE_MACRO_CSTR(Image_Title_Disable);

		CASE_MACRO_CSTR(Image_Background);
		CASE_MACRO_CSTR(Image_Background_Hovered);
		CASE_MACRO_CSTR(Image_Background_Pressed);
		CASE_MACRO_CSTR(Image_Background_Checked);
		CASE_MACRO_CSTR(Image_Background_Disable);

		CASE_MACRO_CSTR(Image_Header);
		CASE_MACRO_CSTR(Image_Header_Hovered);
		CASE_MACRO_CSTR(Image_Header_Pressed);
		CASE_MACRO_CSTR(Image_Header_Checked);
		CASE_MACRO_CSTR(Image_Header_Disable);

		CASE_MACRO_CSTR(Image_Item);
		CASE_MACRO_CSTR(Image_Item_Hovered);
		CASE_MACRO_CSTR(Image_Item_Pressed);
		CASE_MACRO_CSTR(Image_Item_Checked);
		CASE_MACRO_CSTR(Image_Item_Disable);

		CASE_MACRO_CSTR(Image_Separator);
		CASE_MACRO_CSTR(Image_Groove);

		CASE_MACRO_CSTR(Icon_Arrow_Up);
		CASE_MACRO_CSTR(Icon_Arrow_Down);
		CASE_MACRO_CSTR(Icon_Arrow_Left);
		CASE_MACRO_CSTR(Icon_Arrow_Right);

		CASE_MACRO_CSTR(Icon_Title);
		CASE_MACRO_CSTR(Icon_About);
		CASE_MACRO_CSTR(Icon_Critical);
		CASE_MACRO_CSTR(Icon_Information);
		CASE_MACRO_CSTR(Icon_Question);
		CASE_MACRO_CSTR(Icon_Warning);
		CASE_MACRO_CSTR(Icon_Expand);
		CASE_MACRO_CSTR(Icon_Shrink);
	}
	return "UnKnown";
}
BString MainWindow::valueToString(const BValue& value)
{
	BString text;
	if (value.empty())
	{
		text = "nil";
	}
	else if (value.is<bool>())
	{
		bool b = value;
		text << (b ? "true" : "false");
	}
	else if (value.is<char>())
	{
		char c = value;
		text << (int)c << 'c';
	}
	else if (value.is<unsigned char>())
	{
		unsigned char b = value;
		text << (int)b << 'b';
	}
	else if (value.is<short>())
	{
		short s = value;
		text << (int)s << 's';
	}
	else if (value.is<unsigned short>())
	{
		unsigned short us = value;
		text << (int)us << "us";
	}
	else if (value.is<int>())
	{
		int i = value;
		text << i;
	}
	else if (value.is<unsigned int>())
	{
		unsigned int ui = value;
		text << ui << 'u';
	}
	else if (value.is<long long>())
	{
		long long l = value;
		text << l << "l";
	}
	else if (value.is<unsigned long long>())
	{
		unsigned long long ul = value;
		text << ul << "ul";
	}
	else if (value.is<float>())
	{
		float f = value;
		text << f << 'f';
	}
	else if (value.is<double>())
	{
		double d = value;
		text << d;
	}
	else if (value.is<BString>())
	{
		const BString& str = value;
		text << '\"' << str << '\"';
	}
	else if (const BStringList* path = value)
	{
		for (int i = 0; i < path->size(); i++)
			text << path->at(i) << '.';
		text -= '.';
	}
	else
	{
		text = "UnKnown";
	}
	return text;
}

void MainWindow::slotFileButtonClicked(BObject* object)
{
	BButton* button = (BButton*)object;
	const BString& fileName = BFileDialog::OpenFile(this, "Open Image file", "./data");
	if (fileName.size())
	{
		BImage* image = ReadFile<BImage>(fileName);
		BIcon* icon = new BIcon(image);
		button->setIcon(icon);
		BWidget* treeWidget = this->find("tree");
		BStyle* style = treeWidget->style();
		if (!style)
		{
			style = new BStyle();
			treeWidget->setStyle(style);
		}
		style->setImage(Image_Background, image);
	}
}
void MainWindow::slotLoadButtonClicked()
{
	BString currentPath = BApplication::CurrentPath();

	const BString& fileName = _fileNameEdit->text();
	_styleSheetEdit->setFileName(fileName);
	_styleSheetEdit->load();

	BStyleDocument document;
	BStyle* style = document.load(fileName);
	BTreeItem* rootItem = createTreeItem(style);
	rootItem->setName(fileName.name());
	rootItem->setIcon(_rootIcon);
	_treeWidget->clearItems();
	_treeWidget->addTopItem(rootItem);

}

void MainWindow::slotItemDoubleClicked(BObject* object, const BValue& value)
{
	BTableWidget* tableWidget = (BTableWidget*)object;
	BTableItem* item = value;
	if (!item)
	{
		BPoint pos = BCursor::GetPos() - tableWidget->globalPos();
		int row = tableWidget->rowAt(pos.y());
		int column = tableWidget->columnAt(pos.x());
		item = new BTableItem();
		tableWidget->setItem(row, column, item);
	}
	BLineEdit* itemEdit = (BLineEdit*)tableWidget->find("editer");
	itemEdit->setAsset(item);
	itemEdit->setAlign(item->align());
	itemEdit->setRect(item->textArea());
	itemEdit->setText(item->text());
	itemEdit->popup();
}
void MainWindow::slotItemTextEdited(BObject* object, const BValue& value)
{
	BLineEdit* edit = (BLineEdit*)object;
	BTableItem* item = object->asset();
	item->setText(value);
	edit->hide();
}
void MainWindow::slotItemTextEditFocusOut(BObject* object)
{
	BLineEdit* edit = (BLineEdit*)object;
	edit->hide();
}
void MainWindow::slotPolicyButtonClicked(BObject* object, const BValue& value)
{
	BButton* button = dynamic_cast<BButton*>(object);
	BMenu* menu = button->menu();
	menu->setAsset(button);
	int policies = button->asset();
	for (int i = 0; i < menu->count(); i++)
	{
		BAction* action = menu->action(i);
		PolicyFlag policy = action->asset();
		action->setChecked(policies & policy);
	}
}
void MainWindow::slotPolicyMenuTrigger(BObject* object, const BValue& value)
{
	BMenu* menu = dynamic_cast<BMenu*>(object);
	BString text;
	int policies = 0;
	for (int i = 0; i < menu->count(); i++)
	{
		BAction* action = menu->action(i);
		if (action->checked())
		{
			PolicyFlag policy = action->asset();
			policies |= policy;
			text << action->text() << ',';
		}
	}
	text -= ',';
	BButton* button = menu->asset();
	button->setText(text);
	button->setAsset(policies);
	BTableWidget* tableWidget = (BTableWidget*)button->parent();
	if (button->name() == "row-policy")
	{
		tableWidget->setRowPolicy(policies);
	}
	if (button->name() == "column-policy")
	{
		tableWidget->setColumnPolicy(policies);
	}
}

void MainWindow::slotSheetFileNameEdited()
{
	const BString& fileName = _fileNameEdit->text();
	if (fileName.size() && fileName != _styleSheetEdit->fileName())
		_saveFileButton->setEnabled(true);
	else
		_saveFileButton->setEnabled(false);
}
void MainWindow::slotBrowseFileButtonClicked()
{
	const BString& fileName = BFileDialog::OpenFile(this, "Open Image file", "./data");
	if(fileName.size())
	{
		_fileNameEdit->setText(fileName);
	}
}
void MainWindow::slotSaveSheetButtonClicked()
{
	_styleSheetEdit->save();
	_saveFileButton->setEnabled(false);
}
void MainWindow::slotStyleSheetEdited(BObject* object, const BValue& value)
{
	BTextEdit* textEdit = dynamic_cast<BTextEdit*>(object);
	if (textEdit)
	{
		const BString& sheet = textEdit->text();
		BApplication::setStyleSheet(sheet);
	}
}
void MainWindow::slotTreeItemSelected(BObject* object, const BValue& value)
{
	if (BTreeItem* item = value)
	{
		const BStyle* style = item->asset();
		if (!style)
			return;
		_tableWidget->clearItems();
		_tableWidget->setColumnCount(2);
		_tableWidget->setColumnLabel(0, "Name");
		_tableWidget->setColumnLabel(1, "Value");
		const BMap<StyleRole, BValue>& valueMap = style->query("value-map");
		for (auto it = valueMap.begin(); it != valueMap.end(); it++)
		{
			int row = _tableWidget->addRows();
			_tableWidget->setRowLabel(row, BString("value") + it.index());
			_tableWidget->setItem(row, 0, sroleToString(it.key()));
			if (BIcon* icon = it.value())
				_tableWidget->setItem(row, 1, new BButton(icon));
			else if (BImage* image = it.value())
				_tableWidget->setItem(row, 1, new BButton(image));
			else
				_tableWidget->setItem(row, 1, valueToString(it.value()));
		}
		const BMap<StyleRole, BColor>& colorMap = style->query("color-map");
		for (auto it = colorMap.begin(); it != colorMap.end(); it++)
		{
			int row = _tableWidget->addRows();
			_tableWidget->setRowLabel(row, BString("color") + '$' + it.index());
			_tableWidget->setItem(row, 0, sroleToString(it.key()));
			_tableWidget->setItem(row, 1, new BButton(Graph_Square_Fill, it.value()));
		}
		const BMap<StyleRole, BImage*>& imageMap = style->query("image-map");
		for (auto it = imageMap.begin(); it != imageMap.end(); it++)
		{
			int row = _tableWidget->addRows();
			_tableWidget->setRowLabel(row, BString("image") + '$' + it.index());
			_tableWidget->setItem(row, 0, sroleToString(it.key()));
			_tableWidget->setItem(row, 1, new BButton(it.value()));
		}
		const BMap<StyleRole, BIcon*>& iconMap = style->query("icon-map");
		for (auto it = iconMap.begin(); it != iconMap.end(); it++)
		{
			int row = _tableWidget->addRows();
			_tableWidget->setRowLabel(row, BString("icon") + '$' + it.index());
			_tableWidget->setItem(row, 0, sroleToString(it.key()));
			_tableWidget->setItem(row, 1, new BButton(it.value()));
		}
		const BMap<BString, BString>& transMap = style->query("trans-map");
		for (auto it = transMap.begin(); it != transMap.end(); it++)
		{
			int row = _tableWidget->addRows();
			_tableWidget->setRowLabel(row, BString("*trans") + '$' + it.index());
			_tableWidget->setItem(row, 0, it.key());
			_tableWidget->setItem(row, 1, it.value());
		}
		const BMap<BString, BColor>& namedColorMap = style->query("named-color-map");
		for (auto it = namedColorMap.begin(); it != namedColorMap.end(); it++)
		{
			int row = _tableWidget->addRows();
			_tableWidget->setRowLabel(row, BString("*color") + '$' + it.index());
			_tableWidget->setItem(row, 0, it.key());
			_tableWidget->setItem(row, 1, new BButton(Graph_Square_Fill, it.value()));
		}
		const BMap<BString, BImage*>& namedImageMap = style->query("named-image-map");
		for (auto it = namedImageMap.begin(); it != namedImageMap.end(); it++)
		{
			int row = _tableWidget->addRows();
			_tableWidget->setRowLabel(row, BString("*image") + '$' + it.index());
			_tableWidget->setItem(row, 0, it.key());
			_tableWidget->setItem(row, 1, new BButton(it.value()));
		}
		const BMap<BString, BIcon*>& namedIconMap = style->query("named-icon-map");
		for (auto it = namedIconMap.begin(); it != namedIconMap.end(); it++)
		{
			int row = _tableWidget->addRows();
			_tableWidget->setRowLabel(row, BString("*icon") + '$' + it.index());
			_tableWidget->setItem(row, 0, it.key());
			_tableWidget->setItem(row, 1, new BButton(it.value()));
		}
	}
	else
	{
		_tableWidget->clearItems();
	}
}

void MainWindow::styleEvent(const BEvent& event)
{
	if (const BStyle* style = event.value())
	{
		_rootIcon = style->icon("root");
		_subsIcon = style->icon("subs");
		_itemIcon = style->icon("item");
	}
}
